﻿using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace PosClient.Model
{
    [Index("{tablename}_order_id", "Id,OrderNo", true)]
    [Table(Name = "t_order{yyyyMM}", AsTable = "createtime=2025-02-01(1 month)")]
    public class Order : INotifyPropertyChanged
    {
        [Column(IsPrimary = true, IsIdentity = true)]
        public long Id { get; set; }

        private string _StoreCode;
        public string StoreCode
        {
            get => _StoreCode;
            set
            {
                if (value != _StoreCode)
                {
                    _StoreCode = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private string _OrderNo;
        public string OrderNo
        {
            get => _OrderNo;
            set
            {
                if (value != _OrderNo)
                {
                    _OrderNo = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private string _PosNo;
        public string PosNo
        {
            get => _PosNo;
            set
            {
                if (value != _PosNo)
                {
                    _PosNo = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int _WorkNo;
        public int WorkNo
        {
            get => _WorkNo;
            set
            {
                if (value != _WorkNo)
                {
                    _WorkNo = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _OriginAmount;
        public decimal OriginAmount
        {
            get => _OriginAmount;
            set
            {
                if (value != _OriginAmount)
                {
                    _OriginAmount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _PayAmount;
        public decimal PayAmount
        {
            get => _PayAmount;
            set
            {
                if (value != _PayAmount)
                {
                    _PayAmount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _DiscountAmount;
        public decimal DiscountAmount
        {
            get => _DiscountAmount;
            set
            {
                if (value != _DiscountAmount)
                {
                    _DiscountAmount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _PackageAmount;
        public decimal PackageAmount
        {
            get => _PackageAmount;
            set
            {
                if (value != _PackageAmount)
                {
                    _PackageAmount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _CouponAmount;
        public decimal CouponAmount
        {
            get => _CouponAmount;
            set
            {
                if (value != _CouponAmount)
                {
                    _CouponAmount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _ExchangeAmount;
        public decimal ExchangeAmount
        {
            get => _ExchangeAmount;
            set
            {
                if (value != _ExchangeAmount)
                {
                    _ExchangeAmount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _Amount;
        public decimal Amount
        {
            get => _Amount;
            set
            {
                if (value != _Amount)
                {
                    _Amount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private DateTime _CreateTime;
        public DateTime CreateTime
        {
            get => _CreateTime;
            set
            {
                if (value != _CreateTime)
                {
                    _CreateTime = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int _Seq;
        public int Seq
        {
            get => _Seq;
            set
            {
                if (value != _Seq)
                {
                    _Seq = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int _FlagRefund;
        public int FlagRefund
        {
            get => _FlagRefund;
            set
            {
                if (value != _FlagRefund)
                {
                    _FlagRefund = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int _FlagSend;
        public int FlagSend
        {
            get => _FlagSend;
            set
            {
                if (value != _FlagSend)
                {
                    _FlagSend = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private string _Note;
        public string Note
        {
            get => _Note;
            set
            {
                if (value != _Note)
                {
                    _Note = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private string _Phone;
        public string Phone
        {
            get => _Phone;
            set
            {
                if (value != _Phone)
                {
                    _Phone = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int _CardId;
        public int CardId
        {
            get => _CardId;
            set
            {
                if (value != _CardId)
                {
                    _CardId = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private string _CardCode;
        public string CardCode
        {
            get => _CardCode;
            set
            {
                if (value != _CardCode)
                {
                    _CardCode = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private decimal _RoundAmount;
        public decimal RoundAmount
        {
            get => _RoundAmount;
            set
            {
                if (value != _RoundAmount)
                {
                    _RoundAmount = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private string _Username;
        public string Username
        {
            get => _Username;
            set
            {
                if (value != _Username)
                {
                    _Username = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private DateTime _BalanceDate;
        public DateTime BalanceDate
        {
            get => _BalanceDate;
            set
            {
                if (value != _BalanceDate)
                {
                    _BalanceDate = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private string _TransNo;
        public string TransNo
        {
            get => _TransNo;
            set
            {
                if (value != _TransNo)
                {
                    _TransNo = value;
                    NotifyPropertyChanged();
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); //实现通知刷新
        }
    }
}
